/*
 * Alloy Analyzer
 * Copyright (c) 2002 Massachusetts Institute of Technology
 *
 * The Alloy Analyzer is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * The Alloy Analyzer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the Alloy Analyzer; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package alloy.transl;

import alloy.bool.BoolSwitch;

/**
 * Information about values taken by a quantified variable.  A quantified variable
 * ranges over a sequence of relation-valued constants.
 * Constructed by {@link QVarValGenerator}.
 * @see alloy.ast.VarCreator
 * @see alloy.ast.Variable
 */
public class QVarIterationInfo {
    /**
     * The {@link BoolSwitch} that, when set, sets the value of the quantified
     * variable -- the switchable constants in the translation of the variable
     * read this switch.
     */
    private BoolSwitch _boolSwitch;

    /**
     * The sequence of values to be assigned to the quantified variable.  Each value
     * is a <code>long</code> that, when assigned to the {@link #_boolSwitch},
     * will set the translation of the quantified variable to a particular
     * relational constant.
     */
    private long[] _boolSwitchValues;

    /**
     * When all values of the switch set the quantified variable to relational
     * constants containing exactly one tuple, we construct a parallel array which
     * for each value gives the coordinates of that tuple.  Otherwise, null.
     */
    private int[][] _oneTupleCoords;

    /**
     * The translation of the quantified variable; built out of switchable constants
     * that read the {@link #_boolSwitch}.  When the {@link #_boolSwitch} is set
     * to a particular value, the relational constant represented by this
     * translation changes.
     */
    private ExprTransl _qvarTransl;

    QVarIterationInfo(BoolSwitch boolSwitch_, long[] boolSwitchValues_,
		      int[][] oneTupleCoords_, ExprTransl qvarTransl_) {
	_boolSwitch = boolSwitch_;
	_boolSwitchValues = boolSwitchValues_;
	_qvarTransl = qvarTransl_;
	_oneTupleCoords = oneTupleCoords_;
    }

    public BoolSwitch getBoolSwitch() { return _boolSwitch; }
    public long[] getBoolSwitchValues() { return _boolSwitchValues; }
    public ExprTransl getQVarTransl() { return _qvarTransl; }
    public int[][] getOneTupleCoords() { return _oneTupleCoords; }
}


